1. Field of the Invention
The invention relates to computers and computer software. More particularly, the invention relates to a method and apparatus for compiler-optimized code.
2. Description of the Related Art
Generally, programmers and computer users use a program editor to write computer programs and develop software applications in the form of source code. The source code is conventionally written in a high-level programming language, e.g., C++, Java®, Pascal, and the like. To run such computer programs in a computer system, a compiler program must convert the source code into executable code or object code.
Unfortunately, one of the most common contributions to writing inefficient programs is the generation of temporary objects. In one case, while writing programs such as servlets, programmers may use a StringBuffer variable to output HTML to a client device. For example, consider the following concatenated source code statement:string.append(stvar_a+“AND”+strvar_b)
While this programming statement provides a correct source code statement to a compiler, the compiled code when executed creates temporary objects used to complete the concatenation process. For example, if stvar_a contained the object “THIS” and stvar_b contained the object “THAT”, the compiled code when executed would produce a first temporary object “THIS AND”, and then create a second temporary object “THIS AND THAT”, which is then appended to the object “string”. As temporary objects require the processor to store the result of each object for later access during code execution, executing temporary objects leads to an increased processor run-time that may severely affect the program efficiency and may degrade the performance of the program. Therefore, a need exists for a method and apparatus to increase the run-time efficiency of the compiled source code.